function query_role_by_user(roleId, limit, page, offset) {
    $("#data-list").empty();
    //ajax start
    $.ajax({
        url: baseURL + '/auth/api/roleUser/getUserListByRole',
        type: 'post',
        dataType: 'json',
        headers: {'authorities': authorities},
        data: {
            roleId: roleId,
            limit: limit,
            page: page,
            offset: offset,
        },
        success: function (c) {
            console.log(c);
            for (let i = 0; i < c.content.length; i++) {
                $("#data-list").append(
                    '<tr><td class="sn">' + c.content[i].uid + '</td><td class="title">' + c.content[i].name + '</td> <td class="grade">'
                    + c.content[i].username + '</td><td class="">' + c.content[i].orgName + '</td><td class="">' + c.content[i].state + '</td>' +
                    '<td><a data-toggle="modal" class="modify-modal" href="#modify">修改 </a><a class="del"> 删除</a></td></tr>'
                )
            }

        }

    })
}

//jq start
$(function () {
    authorities = $.session.get('authorities');
    console.log(authorities);
    //ajax start
//ajax end
    $("#data-list").on("click", ".show-modal", function () {
        $("#title_show").text($(this).parents('td').siblings(".name").text())
        $("#title_sed_show").text($(this).parents('td').siblings(".account").text())
        $("#title_thd_show").text($(this).parents('td').siblings(".account").text())
        $("#school_show").text($(this).parents('td').siblings(".school").text())
        $("#birthday_show").text($(this).parents('td').siblings(".birthday").text())
        $("#class_show").text($(this).parents('td').siblings(".class").text())
        $("#level_show").text($(this).parents('td').siblings(".level").text())
    })
    $("#data-list").on("click", ".modify-modal", function () {
        $("#title_modal").text($(this).parents('td').siblings(".name").text())
        $("#title_sed_modal").text($(this).parents('td').siblings(".account").text())
        $("#title_thd_modal").text($(this).parents('td').siblings(".account").text())
        $("#school_modal").text($(this).parents('td').siblings(".school").text())
        $("#birthday_modal").text($(this).parents('td').siblings(".birthday").text())
        $("#class_modal").text($(this).parents('td').siblings(".class").text())
        $("#level_modal").text($(this).parents('td').siblings(".level").text())
    })
//jq end
})
//分页 start
$(function () {

    //默认显示数据开始位置
    let pager_num = 0
    let pager_num_ceil = 1
    $("#pager_input").val(1)
    //获取数据总数
    $.ajax({
        url: baseURL + '/auth/api/roleUser/getUserListByRole',
        data: {
            offset: 1,
            limit: 1,
        },
        type: 'post',
        dataType: 'json',
        headers: {'authorities':authorities},
        success: function (e) {
            $("#data_number").text(e.total)
            pager_num_offset = Math.ceil(e.total / 10)
            pager_offset = e.total
        }
    })
//    下一页按钮点击事件
    $("#rarr").click(function () {
        if (pager_num < pager_offset - 10) {
            pager_num = pager_num + 10
            $("#pager_input").val(Math.ceil($("#pager_input").val()) + 1)
            $("#data-list").empty();
            $.ajax({
                url: baseURL + '/auth/api/roleUser/getUserListByRole',
                data: {
                    offset: pager_num,
                    limit: 10,
                },
                type: 'post',
                headers: {'authorities': authorities},
                success: function (c) {
                    for (let i = 0; i < 10; i++) {
                        $("#data-list").append(
                            '<tr><td class="sn">' + c.content[i].uuid + '</td><td class="title">' + c.content[i].dicgroup + '</td> <td class="grade">'
                            + c.content[i].dickey + '</td><td class="">' + c.content[i].dicvalue + '</td><td class="">' + c.content[i].state + '</td> <td class="">' + c.content[i].revision + '</td>' +
                            '<td><a data-toggle="modal" class="modify-modal" href="#modify">修改 </a><a class="del"> 删除</a></td></tr>'
                        )
                    }
                }
            })
        }

    })
//    上一页按钮点击事件
    $("#larr").click(function () {
        if (pager_num > 0) {
            pager_num = pager_num - 10
            $("#pager_input").val(Math.ceil($("#pager_input").val()) - 1)
            $("#data-list").empty();
            $.ajax({
                url: baseURL + '/auth/api/roleUser/getUserListByRole',
                data: {
                    offset: pager_num,
                    limit: 10,
                },
                type: 'post',
                headers: {'authorities': authorities},
                success: function (c) {
                    console.log(c);
                    $("#data-list").empty();
                    for (let i = 0; i < 10; i++) {
                        $("#data-list").append(
                            '<tr><td class="sn">' + c.content[i].uuid + '</td><td class="title">' + c.content[i].dicgroup + '</td> <td class="grade">'
                            + c.content[i].dickey + '</td><td class="">' + c.content[i].dicvalue + '</td><td class="">' + c.content[i].state + '</td> <td class="">' + c.content[i].revision + '</td>' +
                            '<td><a data-toggle="modal" class="modify-modal" href="#modify">修改 </a><a class="del"> 删除</a></td></tr>'
                        )
                    }
                }
            })
        }

    })
//    页码失焦时根据页码跳转
    $("#pager_input").blur(function () {
        let rr = $("#pager_input").val()
        if (rr > 0) {
            if (rr <= pager_num_offset) {
                let rrn = (rr * 10) - 10
                pager_num = rrn
                $("#data-list").empty();
                $.ajax({
                    url: baseURL + '/auth/api/roleUser/getUserListByRole',
                    data: {
                        offset: rrn,
                        limit: 10,
                    },
                    type: 'post',
                    headers: {'authorities': authorities},
                    success: function (c) {
                        console.log(c);
                        $("#data-list").empty();
                        for (let i = 0; i < 10; i++) {
                            $("#data-list").append(
                                '<tr><td class="sn">' + c.content[i].uuid + '</td><td class="title">' + c.content[i].dicgroup + '</td> <td class="grade">'
                                + c.content[i].dickey + '</td><td class="">' + c.content[i].dicvalue + '</td><td class="">' + c.content[i].state + '</td> <td class="">' + c.content[i].revision + '</td>' +
                                '<td><a data-toggle="modal" class="modify-modal" href="#modify">修改 </a><a class="del"> 删除</a></td></tr>'
                            )
                        }
                    }
                })
            } else if (rr > pager_num_offset) {
                alert("没有这么多页")
            }
        } else if (rr < 0) {
            alert("请输入大于0的数")
        }
    });
})
//分页 end

//权限角色数据
//jQ start
var role_user_byrole = []
$(function () {
    //ajax start
    $.ajax({
        url: baseURL + '/admin/api/role/getUserByRole',
        type: 'post',
        dataType: 'json',
        headers: {'authorities': authorities},
        data: {},
        success: function (e) {
            data_list = e.content
            //for i 循环 start
            for (let i = 0; i < data_list.length; i++) {
                $("#role_list").append(
                    '<div id="role_list_id@' + data_list[i].id + '"  class="list-group-item">' + data_list[i].role + '</div>'
                );
                let data = {}
                data.tid = data_list[i].id
                data.nid = 'role_list_id@' + data_list[i].id
                role_user_byrole = role_user_byrole.concat(data)
            }


        }

    })
    //权限角色分组切换
    $("#role_list").on("click", ".list-group-item", function () {
        $(this).siblings().removeClass("active")
        $(this).addClass("active")
        role_list = $(this).attr("id")
        role_list_tid = find_arr(role_user_byrole, 'nid', role_list, 'tid')
        console.log(role_list_tid);
        query_role_by_user(role_list_tid,'0','1','10')
    });
$("#save_user_to_role").click(function (){
    let user_uid_modify = $("#user_uid_modify").val();
    let user_role_id_modify = $("#user_role_id_modify").val();
        //ajax start
            $.ajax({
                url:baseURL+'/auth/api/roleUser/addUserToRole',
                type:'post',
                dataType: 'json',
                headers: {'authorities': authorities},
                data:{
                    userIds: user_uid_modify,
                    roleId: user_role_id_modify,
                },
                success:function (e){
                    console.log(e);
                }

            })
});



})